function varargout = Geografi(varargin)
% GEOGRAFI MATLAB code for Geografi.fig
%      GEOGRAFI, by itself, creates a new GEOGRAFI or raises the existing
%      singleton*.
%
%      H = GEOGRAFI returns the handle to a new GEOGRAFI or the handle to
%      the existing singleton*.
%
%      GEOGRAFI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GEOGRAFI.M with the given input arguments.
%
%      GEOGRAFI('Property','Value',...) creates a new GEOGRAFI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Geografi_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Geografi_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Geografi

% Last Modified by GUIDE v2.5 27-Apr-2011 22:50:19

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Geografi_OpeningFcn, ...
                   'gui_OutputFcn',  @Geografi_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Geografi is made visible.
function Geografi_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Geografi (see VARARGIN)

% Choose default command line output for Geografi
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Geografi wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Geografi_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in GeografiHitungButton.
function GeografiHitungButton_Callback(hObject, eventdata, handles)
global soal1;
global numsoal;
global metode;
global x0 y0 xr yr h h_idx n;
global xn y01 numy0;
global fxy;
global fungsi1;
global numfungsi;
global metodestring;
global hasil1;
global numhasil;

fxy = @(x,y)(0.02*y-0.00004*y^2);
x0 = 0; y0 = 76.4;
xr = 100;
h = 10;
metode = get(handles.GeografiPopup_metode,'Value');

switch(metode)
    case{1}
        [n yr] = Euler(fxy,[x0 xr],y0,h);
        display(yr);
        metodestring = 'Euler';
    case{2}
        [n yr] = Heun(fxy,[x0 xr],y0,h);
        display(yr);
        metodestring = 'Heun';
    case{3}
        [n yr] = Runge_Kutta( [x0,xr], h, y0, fxy, 3);
        display(yr);
        metodestring = 'Runge-Kutta Orde 3';
    case{4}
        [n yr] = Runge_Kutta( [x0 xr], h, y0, fxy, 4);
        display(yr);
        metodestring = 'Runge-Kutta Orde 4';
    case{5}
        [n yr] = Adam_Moulton([x0 xr],h,y0,fxy);
        display(yr);
        metodestring = 'P-C Adams-Moulton';
end;

set(handles.GeografiOutput_P, 'String', num2str(yr(1)));

%------------------------------------------------%
% Pembuatan report
%------------------------------------------------%
% Soal
soal1 = 'P'' = 0.02*P-0.00004*P^2';
numsoal = 1;
% Variabel
% x0 = x0 (variabel dan globalnya sama)
xn = xr;
% h = h (variabel dan globalnya sama)
% n = n (variabel dan globalnya sama)
y01 = y0;
numy0 = 1;
% Fungsi untuk perhitungan
fungsi1 = func2str(fxy);
numfungsi = 1;
% Hasil
hasil1 = yr(1);
numhasil = 1;
% Generate Report
report('DifferentialEquation');

% --- Executes on button press in ListrikHitungButton_tegangan.
function ListrikHitungButton_tegangan_Callback(hObject, eventdata, handles)
% hObject    handle to ListrikHitungButton_tegangan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on selection change in GeografiPopup_metode.
function GeografiPopup_metode_Callback(hObject, eventdata, handles)
% hObject    handle to GeografiPopup_metode (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns GeografiPopup_metode contents as cell array
%        contents{get(hObject,'Value')} returns selected item from GeografiPopup_metode


% --- Executes during object creation, after setting all properties.
function GeografiPopup_metode_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GeografiPopup_metode (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
